package com.itheima.controller;

import com.itheima.exception.MyFileException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: 付益民
 * @create: 2020-09-29-19:57
 */

@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(MyFileException.class)
    @ResponseBody
    public Map se(Exception e){
        HashMap<String, Object> mp = new HashMap<>();
        mp.put("errorMsg",e.getMessage());
        return mp;
    }
}
